<?php
require_once("sesion.class.php");
 
$sesion = new sesion();

if(  $_SESSION["tipo"] == 'ALUMNO')
{   // Se utiliza en todas las pags de adm para que los alumnos no puedan ingresar..
    setcookie("valida", "error", time()+60*60*24*365, "/");
    header("Location: ppalAlumnos.php");
}

if( $usuario == false ) {
   // si no se ha iniciado sesion redirecciona a la pagina login.php
   header("Location: login.php");
} else {
	// Aqui va el contenido de la pagina qu se mostrara en caso de que se haya iniciado sesion
?>
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
	<head>
		<title>Sistema de Inscripci&oacute;n OnLine</title>
		<link rel='stylesheet' type='text/css' href='../css/estilo.css' media='screen' />
                <link rel="icon" type="image/png" href="../images/sio.png">
                
                <link rel="stylesheet" href="../js/treeview/jquery.treeview.css" />
                

                <script src="../js/treeview/lib/jquery.js" type="text/javascript"></script>
                <script src="../js/treeview/lib/jquery.cookie.js" type="text/javascript"></script>
                <script src="../js/treeview/jquery.treeview.js" type="text/javascript"></script>

                <script type="text/javascript" src="../js/treeview/demo/demo.js"></script>
	</head>
	<body background="../images/backgrounds/Believe3.png">
		<div id='content'>
			<div id='cabecera'><?php include('maquetacionCabecera.php'); ?></div>
	
			<div id='menu'><?php $ban=1; include('maquetacionMenu.php'); ?></div>
			
			<div id='contenido'>
                            <center>
				<?php
					include('usuarioLogueado.php');
					include('conexion.php');
					
					if(is_numeric($_POST['id_materia']))
					{
						$e=false;
						$id_materia	=	$_POST['id_materia'];
						$existe=mysql_query("select id_materia from materias where id_materia=$id_materia",$conexion);
								if($exi=mysql_fetch_array($existe))
								{	
									$e=true;
								}										
						if($e==true)
						{
							echo "<br>
								  <fieldset style='width: 450px;'>
									<legend>Modificar datos de la Materia Nro: <b>$id_materia</b></legend>
								  <br>";
								  
							$registros=mysql_query("select * from materias where id_materia=$id_materia",$conexion);
                                                        echo "	<form action='materiasModificaciones3.php' method=POST>
									<table border=0 id=formcontacto>";
							
    										if($reg=mysql_fetch_array($registros))
										{
											echo "<tr>
													<td>
														Materia:
														<br><br>
													</td>
													<td>
														<input type='text'  name='materiaModif' value='$reg[materia]' autocomplete='off' style='width:218px'>
														<br><br>
													</td>
                                                                                                        <td rowspan=2 align='top' style='width:100px;'>
                                                                                                                <img src='../images/objects/books-edit.png' height=100px width=100px>
                                                                                                        </td>
												  </tr>
												  <tr>
													<td>
														C&oacute;digo:
														<br><br>
													</td>
													<td>
														<input type='text'  name='codigoModif' value='$reg[codigo]' autocomplete='off' style='width:218px'>
														<br><br>
													</td>
												  </tr>";
                                                                                } // &reg4--> consulta tabla materias...ver si va en la 91 o en la 130
											  echo "  <tr>
													<td valign='top'>
                                                                                                            Carreras y Comisiones
                                                                                                        </td>
													<td colspan=2 valign='top'>
                                                                                                            <div style='width:324px; height:245px; overflow-x:hidden; overflow-y:scroll;'>
                                                                                                                <ul id='browser' class='filetree'>";
                                                                                                        $query=mysql_query("select id_carrera, carrera from carreras");
                                                                                                        while($car=mysql_fetch_array($query))
                                                                                                        {
                                                                                                            $carrerass=mysql_query("select id_carrera from mat_x_car_x_com where id_materia=$id_materia and id_carrera=$car[id_carrera] and car_enable='SI'");
                                                                                                            if($carr=mysql_fetch_array($carrerass))
                                                                                                            {
                                                            echo "                                              <li class='closed'><span class='folder'><input type='checkbox' name='id_car[]' value='$car[id_carrera]' checked> $car[carrera]</span>
                                                                                                                        <ul>";
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                            echo "                                              <li class='closed'><span class='folder'><input type='checkbox' name='id_car[]' value='$car[id_carrera]'> $car[carrera]</span>
                                                                                                                        <ul>";                                                    
                                                                                                            }
                                                                                                        $query2=mysql_query("select id_comision, comision from comisiones");
                                                                                                        while($com=mysql_fetch_array($query2))
                                                                                                        {
                                                                                                            $comisioness=mysql_query("select id_comision from mat_x_car_x_com where id_materia=$id_materia and id_carrera=$car[id_carrera] and  id_comision=$com[id_comision] and com_enable='SI'");
                                                                                                            if($comm=mysql_fetch_array($comisioness))
                                                                                                            {
                                                            echo "                                                              <li><span class='file'><input type='checkbox' name='id_com[]' value='$car[id_carrera]-$com[id_comision]' checked> $com[comision]</span></li>";
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                            echo "                                                              <li><span class='file'><input type='checkbox' name='id_com[]' value='$car[id_carrera]-$com[id_comision]'> $com[comision]</span></li>";                                                    
                                                                                                            }
                                                                                                        }
                                                            echo "                                                      </ul>
                                                                                                                </li>
                                                                                                        ";
                                                                                                        }
                                                            echo "                                      </ul>
                                                                                                            </div>
													</td>
												  </tr>
                                                                                                  <tr><td colspan=2 align='center'>
												";
										//} // &reg4--> consulta tabla materias...ver si va en la 91 o en la 130
				?>                                              <br>
										<a href="javascript:document.forms[0].submit()"><img alt="image" src="../images/buttons/modificar.png" border=0 /></a> 
										<a href="javascript:document.forms[0].reset()"> <img alt="image" src="../images/buttons/restablecer.png" border=0 /></a>
									</table>
                                <?php                                        echo "<input type='hidden' name='id_materia' value=$id_materia>"         ?>
									</form>
								</fieldset>
							<br /><br />
				<?php
						}
                                                else//fin de si existe
						{
                                                                echo "<table border=0><tr><td><img src='../images/objects/books-denied.png'></td><td>
													<b style='font-size:20px; color:red;'>Esta materia no existe<br />o no est&aacute; habilitada</b><br>
												</td></tr></table>";
								echo "<h2>&iquest;Desea modificar otra materia?</a></h2><br>";
								echo "	<a href='materiasModificaciones.php'><img src='../images/buttons/si.png' border=0></a>
										&nbsp;&nbsp;&nbsp;&nbsp;
										<a href='principal.php'><img src='../images/buttons/no.png' border=0></a>";
                                                    }
					} // fin de is_numeric
					else
					{
						echo "<table border=0><tr><td><img src='../images/objects/books-denied.png'></td><td>
								<b style='font-size:20px; color:red;'>Debe ingresar un n&uacute;mero de ID<br />para modificar una materia.</b>
							  </td></tr></table>";
						echo "<h2>&iquest;Desea modificar otra materia?</a></h2><br>";
						echo "	<a href='materiasModificaciones.php'><img src='../images/buttons/si.png' border=0></a>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<a href='principal.php'><img src='../images/buttons/no.png' border=0></a>";
					}
                                  ?>
                            <center>
			</div>
						
			<div id='pie'><?php include('maquetacionPie.php'); ?></div>
		</div>
	</body>
</html>
<?php
	}
?>